

function save_center() {
    new Vue({
        el: '#save_center',
        data() {
            return {
                topnavlist: {},
                save_tabs: ['收藏的商品', '关注的店铺'],
                nowIndex: 0,
                changeSave: true,
                ischeck: false,
                arr: [],
                allindex:'',
                href: "",
                ispicker: false,
                brands: [
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                    { src: 'https://dummyimage.com/182x230/79b0f2', shop_name: '2017年秋季新款双排扣羊毛短裤妮 子外套上衣', num: '189', price: '360' },
                ],
                save_shop: [
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                    { src: 'https://dummyimage.com/232x180/79b0f2', shop_name: 'Xx品牌专卖店' },
                ],
                pageNo: 1,
                count: 0,
                ids:[],
            }
        },
        methods: {
            toggleTabs: function (index) {
                this.nowIndex = index;
                this.changeSave = true;
                this.ischeck = false;
                this.ispicker = false;
                this.arr = this.allindex = [];
            },
            listen: function (index) {
                alert(index);
            },
            changesave: function () {
                this.arr = this.allindex = [];
                if (this.changeSave === true) {
                    this.changeSave = false;
                    this.ispicker = true;
                } else {
                    this.changeSave = true;
                    this.ispicker = false;
                    this.ischeck = false;
                }
            },
            checkAll: function () {
                this.arr = this.allindex = [];
                if (this.ischeck === true) {
                    this.ischeck = false;
                    this.ispicker = true;
                } else {
                    this.ischeck = true;
                    this.ispicker = false;
                }
            },
            checkOne: function (index,id) {
                let arr = this.arr;
                if (this.ispicker === true && arr.indexOf(index) == -1) {
                    arr.push(index);
                    this.allindex = arr;
                } else {
                    this.ischeck = false;
                    this.ispicker = true;
                    if (this.ispicker === true && arr.indexOf(index) == -1) {
                        arr.push(index);
                        this.allindex = arr;
                    }else{
                        arr.splice(arr.indexOf(index), 1);
                    }
                }
                if(arr.length == 10){ // 10替换成每页返回的数据个数
                    this.ischeck = true;
                }else{
                    this.ischeck = false;
                }
                console.log(index);
            },
            productList() {
                let that = this;
                axios({
                    method: 'get',
                    url: urlParam.domain() + '/api/productFollow/pcFollowList',
                    params: {
                        pageNo: this.pageNo - 1,
                        token: urlParam.token()
                    },
                    //  responseType: 'stream',
                }).then(function(response) {
                    if (response.data.code == 401) {
                        userLogin.ifLogin();
                    } else {
                        that.brands = response.data.data.productFollows;
                        that.count = getPageCount(response.data.data.count, 10);
                        console.log(that.brands);
                    }
                });
            },
            shopList() {
                let that = this;
                axios({
                    method: 'get',
                    url: urlParam.domain() + '/api/user/pcFocusShop',
                    params: {
                        pageNo: this.pageNo - 1,
                        token: urlParam.token()
                    },
                    //  responseType: 'stream',
                }).then(function(response) {
                    if (response.data.code == 401) {
                        userLogin.ifLogin();
                    } else {
                        // that.save_shop = response.data.data.userFocusShops;
                        // that.count = getPageCount(response.data.data.count, 10);
                    }
                });
            },
            quxiaoproduct(){
                alert(0);
                console.log(this.allindex);
            },
        },
        created() {
            this.productList();
        },
    })
}
/* 评价 */
function evaluate() {
    evaluate = new Vue({
        el: '#evaluate',
        data() {
            return {
                value1: 1,//商家服务 评分
                value2:1,//物流服务 评分
                valueList:[],//商品描述 评分
                crumblist: [
                    { text: '评价订单' },
                ],
                form: [],
                imageUrl: '',
                checked: true,
                urlStream: [], //url所带参数
                orderDetatil: {},
                preimg: {
                    base64: [""], //这个 preimg.base64 才是 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                preimgList:[],//循环创建的 上传图片组件
                productComment:{
                    businessId:0,//店铺id
                    logisticsService:1,//物流服务 1~5
                    merchantService:1,//商家服务1~5
                    orderId:0,//订单id
                    productCommentContents:[],//商品评价内容
                },//提交对象
                isAnonymityList:[],
            }
        },
        methods: {
            handleAvatarSuccess(res, file) {
                this.imageUrl = URL.createObjectURL(file.raw);
            },
            beforeAvatarUpload(file) {
                const isJPG = file.type === 'image/jpeg';
                const isLt2M = file.size / 1024 / 1024 < 2;

                if (!isJPG) {
                    this.$message.error('上传头像图片只能是 JPG 格式!');
                }
                if (!isLt2M) {
                    this.$message.error('上传头像图片大小不能超过 2MB!');
                }
                return isJPG && isLt2M;
            },
            getData() {
                this.urlStream = urlParam.href();
                this.getOrderInfo();
            },
            getOrderInfo() {
                let that = this;
                axios({
                    method: 'get',
                    url: urlParam.domain() + '/api/order/detail',
                    params: {
                        orderId: this.urlStream.orderId,
                        token: urlParam.token()
                    },
                    //  responseType: 'stream',
                }).then(function(response) {
                    if (response.data.code == 401) {
                        userLogin.ifLogin();
                    } else {
                        for(var i=0;i<response.data.data.orderProducts;i++){
                            var obj="that.preimg"+i;
                            obj={
                                base64: [""], //这个 preimg.base64 才是 预览图
                                url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                            }
                        }
                        that.orderDetatil = response.data.data;
                        var obj=[];
                        for(var i=0;i<that.orderDetatil.orderProducts.length;i++){
                            obj[i]={
                                base64: [""], //这个 preimg.base64 才是 预览图
                                url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                            };
                            that.valueList[i]=1;
                        }
                        that.preimgList=obj;
                    }
                });
            },
            save(){
                this.productComment.businessId=this.orderDetatil.sellerId;
                this.productComment.logisticsService=this.value2;
                this.productComment.merchantService=this.value1;
                this.productComment.orderId=this.orderDetatil.orderId;
                let that=this;
                for(var i=0;i<that.valueList.length;i++) {
                    var obj={};
                    obj.commodityDescription=that.valueList[i];
                    obj.content=that.form[i];
                    obj.orderProductId=that.orderDetatil.orderProducts[i].orderProductId;
                    var pic="";
                    for(var j=0;j<that.preimgList[i].url.length;j++){
                        pic+=that.preimgList[i].url[j]+',';
                    }
                    obj.picture=pic;
                    if(that.isAnonymityList[i]==true){
                        obj.isAnonymity=0;
                    }else{
                        obj.isAnonymity=1;
                    }
                    obj.productNumber=that.orderDetatil.orderProducts[i].productNumber;
                    that.productComment.productCommentContents.push(obj);
                }
                axios({
                    method: 'Post',
                    url: urlParam.domain() + '/comment/save?token='+urlParam.token(),
                    data: JSON.stringify(that.productComment),
                    headers: { "Content-Type": "application/json"},
                   // responseType: 'stream',
                }).then(function(response) {
                    history.back(-1);
                });
            },
            back(){
               history.back(-1);
            },
        },
        created() {
            this.getData();
        }

    })
}


/* 个性定制列表 */

function cust_list() {
    new Vue({
        el: '#cust_list',
        data() {
            return {
                topnavlist: {},
                cust_list: ['全部定制', '待承接', '待付款', '待收货', '待评价'],
                nowIndex: 0,
            }
        },
        methods: {
            toggleTabs: function(index) {
                this.nowIndex = index;
            },
            listen: function(index) {
                alert(index);
            }
        },
    })
}

/* 个性定制待承接 */

function custom_daichengjie() {
    new Vue({
        el: '#custom_daichengjie',
        data() {
            return {
                crumblist: [
                    { text: '我的聚衣' },
                    { text: '个性定制' },
                    { text: '定制编号:123333333' }
                ]
            }
        },
    })
}


/* 评价列表 */

function pingjia_list() {
    new Vue({
        el: '#pingjia_list',
        data() {
            return {
                topnavlist: {},
                pingjia_list: ['待评价', '待追评', '已评价'],
                nowIndex: 0,
            }
        },
        methods: {
            toggleTabs: function(index) {
                this.nowIndex = index;
            },
            listen: function(index) {
                alert(index);
            }
        },
    })
}

/* 会员中心 */
function huiyuan() {
    new Vue({
        el: '#huiyuan',
        data() {
            return {
                topnavlist: {},

            }
        },
    })
}

/* 我的余额 */
function balance() {
    new Vue({
        el: '#balance',
        data() {
            return {
                topnavlist: {},
                userInfo: userLogin.userInfo(),
                current: 1, //当前页
                countSize: 0, //总页数
                moneyInfo: [], //余额明细

            }
        },
        methods: {
            getData() {
                var that = this;
                axios({
                    url: urlParam.domain() + "/api/user/getMoneyInfoPC",
                    method: 'get',
                    params: {
                        token: urlParam.token(),
                        current: that.current,
                    }
                }).then(result => {
                    that.countSize = result.data.data.total;
                    that.moneyInfo = result.data.data.rows;

                });
            },
            listen: function(index) {
                this.current = index;
            },
            //充值
            addMoney() {

            },
        },
        created() {
            this.getData();
        }
    })
}
/* 我的积分 */
function score() {
    new Vue({
        el: '#score',
        data() {
            return {
                topnavlist: {},
                current: 1, //当前页
                countPage: 0, //总页数
                listPage: [], //分页信息
                countScore: 0,
                userScore: 0
            }
        },
        methods: {
            getData() {
                this.userScore = userLogin.userInfo().score;
                this.getList();
            },
            listen: function(index) {
                this.current = index;
                this.getList();
            },
            getList() {
                var that = this;
                axios({
                    url: urlParam.domain() + "/api/user/getScorePC",
                    method: "get",
                    params: {
                        token: urlParam.token(),
                        current: that.current
                    }
                }).then(result => {
                    that.listPage = result.data.rows;
                    that.countPage = result.data.total;
                })
            }
        },
        created() {
            this.getData();
        }
    })
}

/* 我的优惠券 */
function coupon() {
    new Vue({
        el: '#coupon',
        data() {
            return {
                coupon_tabs: ['可使用', '已使用', '已过期'],
                nowIndex: 0,
                pageCoupon: [], //优惠券集合
                current: 1, //当前第几页
                countPage: 0, //总页数
            }
        },
        methods: {
            getData() {
                this.pageList();
            },
            toggleTabs: function(index) {
                this.nowIndex = index;
                this.current = 1;
                this.pageList();
            },
            listen: function(index) {
                this.current = index;
                this.pageList();
            },
            pageList() {
                userLogin.ifLogin();
                var that = this;
                axios({
                    url: urlParam.domain() + "/api/user/getCouponPC",
                    method: "get",
                    params: {
                        token: urlParam.token(),
                        flag: that.nowIndex,
                        current: that.current
                    }
                }).then(result => {
                    that.pageCoupon = result.data.data.rows;
                    that.countPage = result.data.data.total;
                    console.log(result.data.data.rows);
                })
            }
        },
        created() {
            this.getData();
        }
    });
}
/* 退款管理 */
function refund() {
    new Vue({
        el: '#refund',
        data() {
            return {
                refund_tabs: ['全部', '待处理', '已拒绝', '已处理,并退款'],
                nowIndex: 0,
            }
        },
        methods: {
            toggleTabs: function(index) {
                this.nowIndex = index;
            },
            listen: function(index) {
                alert(index);
            }
        },
    })
}
/* 售后管理 */
function afterSale() {
    new Vue({
        el: '#afterSale',
        data() {
            return {
                afterSale_tabs: ['申请售后', '申请记录'],
                nowIndex: 0,
            }
        },
        methods: {
            toggleTabs: function(index) {
                this.nowIndex = index;
            },
            listen: function(index) {
                alert(index);
            }
        },
    })
}

/* 已开发票 申请退货 */

function custom_returnGoods() {
    new Vue({
        el: '#custom_returnGoods',
        data() {
            return {
                crumblist: [
                    { text: '我的聚衣' },
                    { text: '个性定制' },
                    { text: '定制编号:123333333' }
                ],
                num1: 1,
                value: '',
                options: [{}],
                imageUrl: '',
                ruleForm: {
                    name: '',
                    region: '',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: ''
                },
                rules: {
                    name: [
                        { required: true, message: '', trigger: 'blur' },
                    ],
                    region: [
                        { required: true, message: '', trigger: 'change' }
                    ],
                }

            }
        },
    })
}
/* 我的发票 */
function invoice() {
    new Vue({
        el: '#invoice',
        data() {
            return {
                pingjia_list: ['我的发票'],
                nowIndex: 0,
            }
        },
        methods: {
            toggleTabs: function(index) {
                this.nowIndex = index;
            },
            listen: function(index) {
                alert(index);
            }
        },
    })
}